import request from '../../utils/request'
import { requestString } from '../../utils/request'

/**
 * 分页查询来账
 *
 * @param name			来账客户名称（付款人）
 * @param account		来账账号
 * @param never			true: 来账从未被认领过
 * @param claim			true: 部分认领中，未提交财务审核
 * @param approval		true：部分财务审核中
 * @param confirm		true: 部分财务审核通过
 * @param balance		true: 仍有结余
 * @param done			true：认领完毕
 * @param status		0: 已删除 1: 草稿 2: 可认领
 * @param lesseeCode	租户编码
 * @param page			分页参数
 * @return
 */
export async function getListForPage(data) {

    return request(apiPath.mc + "/api/revenue", {
        method: 'get',
        data
    });
}



/**
 * 新增来账
 *
 * @param revenueForm
 * @param bindingResult
 * @return
 */
export async function createRevenue(data) {
    return request(apiPath.mc + "/api/revenue", {
        method: 'post',
        data
    });
}


/**
 * 更新来账
 *
 * @param profitForm
 * @param bindingResult
 * @return
 */
export async function updateRevenue(data) {
    return request(apiPath.mc + "/api/revenue", {
        method: 'put',
        data
    });
}

/**
 * 根据id删除来账
 *
 * @param id
 * @return
 */
export async function deleteRevenueById({ id }) {
    return request(apiPath.mc + "/api/revenue/" + id, {
        method: 'delete'

    });
}

/**
 * 根据id获取来账
 *
 * @param id
 * @return
 */
export async function getRevenueById({ id }) {
    return request(apiPath.mc + "/api/revenue/" + id, {
        method: 'get'
    });
}

/**
 * 来账认领
 *
 * @return
 */
export async function claimRevenue(data) {
    return request(apiPath.mc + "/api/revenue/" + data.revenueId + "/claim", {
        method: 'POST',
        data
    });
}

/**
 * 批量来账认领
 *
 */
export async function batchClaimRevenue(data) {
    return requestString(apiPath.mc + "/api/revenue/" + data.revenueId + "/batchClaim", {
        method: 'POST',
        data: data.list
    });
}

/**
 * 取消来账认领
 *
 * @param claimId
 * @return
 */
export async function unClaimRevenue(data) {
    return request(apiPath.mc + "/api/revenue/" + data.claimId + "/unClaim", {
        method: 'POST'
    });
}
/**
 * 根据来账id查询已认领的费用
 *
 * @param revenueId
 *
 */
export async function getListByBevenueId(data) {
    return request(apiPath.mc + "/api/revenue/" + data.revenueId + "/claimed", {
        method: 'get',
        data
    })
}
/**
 * 根据订单号、客户名称模糊查询还有余额未认领完的费用
 *
 * @param orderNo
 * @param cstName
 * @param page
 * @return
 */
export async function getUnClaimForPage(data) {
    return request(apiPath.mc + "/api/odCharge/unClaim", {
        method: 'get',
        data
    });
}
/**
 * 费用认领状态批量修改 包括：1.财务审核通过 2.财务退回
 *
 * @param revenueId
 * @param status
 * @param memo
 * @return
 */
export async function approvalClaim(data) {
    return request(apiPath.mc + "/api/revenue/" + data.revenueId + "/approval", {
        method: 'PUT',
        data
    });
}

/**
 * 单条认领记录提交审核
 *
 * @param claimId
 * @return
 */
export async function applyClaim(data) {
    return request(apiPath.mc + "/api/revenue/" + data.claimId + "/apply", {
        method: 'post'
    });
}

/**
 * 批量取消认领
 *
 */
export async function batchCancelClaim({ ids }) {
    return requestString(apiPath.mc + "/api/revenue/batchCancelClaim", {
        method: 'post',
        data: ids
    });
}

/**
 * 批量提交认领
 *
 */
export async function batchSubmitClaim({ ids }) {
    return requestString(apiPath.mc + "/api/revenue/batchSubmitClaim", {
        method: 'post',
        data: ids
    });
}